<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>hello_react</title>
</head>

<body>
    <!-- 准备一个“容器” -->
    <div id="test"></div>

    <!-- 引入 react 核心库 -->
    <script src="../js/react.development.js"></script>
    <!-- 引入 react-dom. 用于支持 react 操作 dom -->
    <script src="../js/react-dom.development.js"></script>
    <!-- 引入babel. 用于将 jsx 转换为 js -->
    <script src="../js/babel.min.js"></script>
    <script type="text/babel"> /* 这里必须写 babel */
        class Demo extends React.Component {
            render() {
                return (
                    <div>
                        <input ref={c => this.input1 = c} type="text" placeholder="点击按钮展示数据" />
                        <button onClick={this.showData}>点击展示左侧数据</button>
                        <input ref={c => this.input2 = c} onBlur={this.blurData} type="text" placeholder="失焦展示数据" />
                    </div>
                )
            }
            showData = () => {
                alert(this.input1.value)
            }
            blurData = () => {
                alert(this.input2.value)
            }
        }
        ReactDOM.render(<Demo />, document.getElementById("test"))
    </script>
</body>

</html>